package chuangyi.com.org.ViewModel;

import android.app.Activity;
import android.content.Context;
import android.databinding.Bindable;
import android.support.annotation.LayoutRes;
import android.view.View;

import chuangyi.com.org.DOMIHome.BR;
import chuangyi.com.org.DOMIHome.Fragments.CommonFragment;
import chuangyi.com.org.DOMIHome.HomeActivity;
import chuangyi.com.org.DOMIHome.R;
import chuangyi.com.org.DOMIHome.adapter.BindingListItem;

/**
 * Created by zxh on 16/12/11.
 */

public class ApplyItem extends BindingListItem {
    private int stepIndex;
    private boolean completed;
    private int imageSrc;
    private String title;

    @Bindable
    public boolean isCompleted() {
        return completed;
    }

    public void setCompleted(boolean completed) {
        this.completed = completed;
        if(completed){
            setImageSrc(R.mipmap.apply3);
        }
    }

    @Bindable
    public int getImageSrc() {
        return imageSrc;
    }

    public void setImageSrc(int imageSrc) {
        this.imageSrc = imageSrc;
    }

    @Bindable
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public ApplyItem(Context context, @LayoutRes int layoutId, int index){
        super(context, layoutId);
        this.stepIndex = index;
        this.imageSrc = R.mipmap.apply2;
    }

    public void onClickItem(View view){
//        switch (stepIndex){
//            case 1:
//                ApplyExpertContractModel model = new ApplyExpertContractModel(getContext());
//                CommonFragment fragment = new CommonFragment();
//                fragment.setLayoutId(R.layout.f_apply_expert_contract);
//                fragment.setVariableId(BR.contract);
//                fragment.setDataModel(model);
//                HomeActivity.switchFragment((Activity)getContext(), fragment);
//                break;
//            case 2:
//                break;
//            case 3:
//                break;
//            case 4:
//                break;
//        }
        ApplyExpertContractModel model = new ApplyExpertContractModel(getContext());
        CommonFragment fragment = new CommonFragment();
        fragment.setLayoutId(R.layout.f_apply_expert_contract);
        fragment.setVariableId(BR.contract);
        fragment.setDataModel(model);
        HomeActivity.switchFragment((Activity) getContext(), fragment);
    }
}
